import { unlink } from "node:fs/promises";
import { $ } from 'bun';

let i = 0;
while (true) {
    while (!(await Bun.file(`${i + 1}.wav`).exists())) {
        await new Promise(r => setTimeout(r, 200));
    }
    console.log(i);
    await $`ffplay -nodisp -autoexit ${i}.wav`.quiet();
    await unlink(`${i}.wav`);
    i++;
}